import { Routes, Route,Navigate} from "react-router";
import {lazy} from "react";
// import Game from "./pages/game";
// import Home from "./pages/home";
// import List from "./pages/list";
// import Todo from "./pages/todolist/todo/index";


function MyGameRoutes() {
  
  const routes = [
    {
    path: "/",
    element: Navigate,
    redirect: "/home",
  },
    {
      path: "/home",
      element:lazy(()=>import(/*webpackChunkName:'manage',webpackPrefetch:true*/'./pages/home')),
    },
    {
      path: "/game",
      element: lazy(()=>import(/*webpackChunkName:'manage',webpackPrefetch:true*/'./pages/game')),
    },
    {
      path: "/list",
      element: lazy(()=>import(/*webpackChunkName:'manage',webpackPrefetch:true*/'./pages/list')),
    },
    {
      path: "/todo",
      element: lazy(()=>import(/*webpackChunkName:'manage',webpackPrefetch:true*/'./pages/todolist/todo')),
    },
  ];
  const doRoutes = (routes) => {
    return routes.map((item) => {
      return ( <Route key={item.path} path={item.path} element={
        item.redirect ? (
              <>
                  <Navigate to={`${item.redirect}`} replace />
              </>
          ) : (
              <item.element />
          )
      }
      >
      </Route>)
    });
  };
  return  <Routes>{doRoutes(routes)}</Routes>

}
export default MyGameRoutes;
